-
Notifications
You must be signed in to change notification settings - Fork 469
Preserve jsx with custom module #7577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/win32-x64
commit: |
Original reported via https://github.com/Fattafatta/rescript-v12-test |
@nojaf could this be involved? let element_binding =
match config.module_ |> String.lowercase_ascii with
| "react" -> Lident "ReactDOM"
| _generic -> module_access_name config "Elements"
in |
This example also has the issue, without using a custom module: @@config({
flags: ["-bs-jsx", "4", "-bs-jsx-preserve"],
})
module React = {
type component<'props> = Jsx.component<'props>
type element = Jsx.element
external jsx: (component<'props>, 'props) => element = "jsx"
type fragmentProps = {children?: element}
external jsxFragment: component<fragmentProps> = "Fragment"
}
let _fragment = <> {Jsx.string("Hello, world!")} </> |
Cutting down further, this seems the problematic line. So somehow defining the module React = {
include React
// This is the problematic line:
external jsx: (component<'props>, 'props) => element = "jsx"
} |
This with module React = {
include React
@module("react/jsx-runtime")
external jsx: (component<'props>, 'props) => element = "jsx"
} |
…ithout a `@module` attribute Fixes #7577
…ithout a `@module` attribute Fixes #7577
Indeed the generated lambda is slightly different in the identifier used (where dump recognises "jsx"). Fixed in #7591 |
…ithout a `@module` attribute Fixes rescript-lang#7577
It was mentioned on the forum that
-bs-jsx-preserve
doesn't work in combination with-bs-jsx-module
.Sample to reproduce:
dune exec bsc -- ./tests/tests/src/jsx_preserve_custom_module.res
@cristianoc PPX seems fine, and I believe the information gets lost before reaching
js_dump
.Would you have any guess what is different for this code path?